<?php
class FunctionData{
	public static $static = null;
	public static $fbdbconnect = null;
	static function readKey($key){
		{if(!isset( FunctionData::$static  ) ||  FunctionData::$static  ==null){ FunctionData::$static   = new Memcache; FunctionData::$static  ->connect("127.0.0.1" , 11215 ) or die ("Could not connect");};} ;
		$data =   FunctionData::$static  ->get( $key ) ;
		return $data;
	}
	static function writeKey($key,$bytes){
		{if(!isset( FunctionData::$static  ) ||  FunctionData::$static  ==null){ FunctionData::$static   = new Memcache; FunctionData::$static  ->connect("127.0.0.1" , 11215 ) or die ("Could not connect");};} ;
		{if( FunctionData::$static  ->get( $key )==null) FunctionData::$static  ->set( $key , $bytes );else  FunctionData::$static  ->replace( $key , $bytes );} ;
	}
	static function incKey($key){
		{if(!isset( FunctionData::$static  ) ||  FunctionData::$static  ==null){ FunctionData::$static   = new Memcache; FunctionData::$static  ->connect("127.0.0.1" , 11215 ) or die ("Could not connect");};} ;
		{if( FunctionData::$static  ->get( $key )!=null) FunctionData::$static  ->increment( $key );else  FunctionData::$static  ->set( $key ,1);} ;
	}
	static function registerAnUserId(){
		{if(!isset( FunctionData::$static  ) ||  FunctionData::$static  ==null){ FunctionData::$static   = new Memcache; FunctionData::$static  ->connect("127.0.0.1" , 11215 ) or die ("Could not connect");};} ;
		$next_id =  FunctionData::$static  ->get( "nextid"  ) ;
		$numof_newid =  FunctionData::$static  ->get( "mng_numof_newid"  ) ;
		if($next_id == null){
			$next_id = 1;
			$numof_newid = 0;
		}
		$numof_newid++;
		{if( FunctionData::$static  ->get( "nextid"  )==null) FunctionData::$static  ->set( "nextid"  , $next_id+1 );else  FunctionData::$static  ->replace( "nextid"  , $next_id+1 );} ;
		{if( FunctionData::$static  ->get( "id_status_" .$next_id )==null) FunctionData::$static  ->set( "id_status_" .$next_id , 0  );else  FunctionData::$static  ->replace( "id_status_" .$next_id , 0  );} ;
		{if( FunctionData::$static  ->get( "mng_numof_newid"  )==null) FunctionData::$static  ->set( "mng_numof_newid"  , $num_of_newid );else  FunctionData::$static  ->replace( "mng_numof_newid"  , $num_of_newid );} ;
		return $next_id;
	}
	static function checkIDValid($id){
		{if(!isset( FunctionData::$static  ) ||  FunctionData::$static  ==null){ FunctionData::$static   = new Memcache; FunctionData::$static  ->connect("127.0.0.1" , 11215 ) or die ("Could not connect");};} ;
		$identify =  FunctionData::$static  ->get( "id_" .$id ) ;
		return($identify!=null);
	}
	static function checkIdentifyValid($identify){
		{if(!isset( FunctionData::$static  ) ||  FunctionData::$static  ==null){ FunctionData::$static   = new Memcache; FunctionData::$static  ->connect("127.0.0.1" , 11215 ) or die ("Could not connect");};} ;
		$id =  FunctionData::$static  ->get( "mail_" .$identify ) ;
		if($id != null){
			return true;
		}else{
			$id =  FunctionData::$static  ->get( "guest_" .$identify ) ;
			return ($id != null);
		}
	}
	static function getIdentifyFromId($id){
		{if(!isset( FunctionData::$static  ) ||  FunctionData::$static  ==null){ FunctionData::$static   = new Memcache; FunctionData::$static  ->connect("127.0.0.1" , 11215 ) or die ("Could not connect");};} ;
		$identify =  FunctionData::$static  ->get( "id_" .$id ) ;
		if($identify!=null){
			return implode(array_map("chr",  $identify )) ;
		}else{
		}
		return null;
	}
	static function getIDFromIdentify($identify){
		{if(!isset( FunctionData::$static  ) ||  FunctionData::$static  ==null){ FunctionData::$static   = new Memcache; FunctionData::$static  ->connect("127.0.0.1" , 11215 ) or die ("Could not connect");};} ;
		$id =  FunctionData::$static  ->get( "mail_" .$identify ) ;
		if($id == null){
			$id =  FunctionData::$static  ->get( "guest_" .$identify ) ;
			if($id == null)return -1;
		}
		return $id;
	}
	static function getDisplayNameOfId($id){
		return self::getIdentifyFromId($id);
	}
	static function getAccountTypeOfId($id){
		{if(!isset( FunctionData::$static  ) ||  FunctionData::$static  ==null){ FunctionData::$static   = new Memcache; FunctionData::$static  ->connect("127.0.0.1" , 11215 ) or die ("Could not connect");};} ;
		$type = 0 +  FunctionData::$static  ->get( "id_status_" .$id ) ;
		if($type == 1 ) return 1 ;
		if($type == 2 ) return 2 ;
		return 0 ;
	}
	static function connectIdAndMailAddress($id,$email_address){
		{if(!isset( FunctionData::$static  ) ||  FunctionData::$static  ==null){ FunctionData::$static   = new Memcache; FunctionData::$static  ->connect("127.0.0.1" , 11215 ) or die ("Could not connect");};} ;
		$idstatus =  FunctionData::$static  ->get( "id_status_" .$id ) ;
		if($idstatus == 0 ){
			$numof_newid =  FunctionData::$static  ->get( "mng_numof_newid"  ) ;
			$numof_newid--;
			{if( FunctionData::$static  ->get( "mng_numof_newid"  )==null) FunctionData::$static  ->set( "mng_numof_newid"  , $numof_newid );else  FunctionData::$static  ->replace( "mng_numof_newid"  , $numof_newid );} ;
		}
		{if( FunctionData::$static  ->get( "mail_" .$email_address )==null) FunctionData::$static  ->set( "mail_" .$email_address , $id );else  FunctionData::$static  ->replace( "mail_" .$email_address , $id );} ;
		{if( FunctionData::$static  ->get( "id_" .$id )==null) FunctionData::$static  ->set( "id_" .$id , unpack('C*', $email_address )  );else  FunctionData::$static  ->replace( "id_" .$id , unpack('C*', $email_address )  );} ;
		{if( FunctionData::$static  ->get( "id_status_" .$id )==null) FunctionData::$static  ->set( "id_status_" .$id , 1  );else  FunctionData::$static  ->replace( "id_status_" .$id , 1  );} ;
	}
	static function checkEmailRegisted($mail_address){
		{if(!isset( FunctionData::$static  ) ||  FunctionData::$static  ==null){ FunctionData::$static   = new Memcache; FunctionData::$static  ->connect("127.0.0.1" , 11215 ) or die ("Could not connect");};} ;
		$id =  FunctionData::$static  ->get( "mail_" .$mail_address ) ;
		return ($id != null);
	}
	static function readAccountId($mail_address){
		{if(!isset( FunctionData::$static  ) ||  FunctionData::$static  ==null){ FunctionData::$static   = new Memcache; FunctionData::$static  ->connect("127.0.0.1" , 11215 ) or die ("Could not connect");};} ;
		$id =  FunctionData::$static  ->get( "mail_" .$mail_address ) ;
		return ($id != null)?$id:-1;
	}
	static function getEmailAddressFromId($id){
		{if(!isset( FunctionData::$static  ) ||  FunctionData::$static  ==null){ FunctionData::$static   = new Memcache; FunctionData::$static  ->connect("127.0.0.1" , 11215 ) or die ("Could not connect");};} ;
		$email_address =  FunctionData::$static  ->get( "id_" .$id ) ;
		if($email_address!=null){
			return implode(array_map("chr",  $email_address )) ;
		}else{
		}
		return null;
	}
	static function checkEmailUsed($mail_address){
		{if(!isset( FunctionData::$static  ) ||  FunctionData::$static  ==null){ FunctionData::$static   = new Memcache; FunctionData::$static  ->connect("127.0.0.1" , 11215 ) or die ("Could not connect");};} ;
		if(!FunctionData::checkEmailRegisted($mail_address)){
			if( FunctionData::$static  ->get( "mail_confirm_" .$mail_address )  == null){
				return false;
			}
		}
		return true;
	}
	static function readAccountRegisterInfo($email_address){
		{if(!isset( FunctionData::$static  ) ||  FunctionData::$static  ==null){ FunctionData::$static   = new Memcache; FunctionData::$static  ->connect("127.0.0.1" , 11215 ) or die ("Could not connect");};} ;
		$reg_data =  FunctionData::$static  ->get( "mail_reginfo_" .$email_address ) ;
		if($reg_data!=null){
			return DataUserRegister::swap(ByteBuffer::wrap( $reg_data ) );
		}
		return null;
	}
	static function writeAccountRegisterInfo($email_address,$account_reg){
		{if(!isset( FunctionData::$static  ) ||  FunctionData::$static  ==null){ FunctionData::$static   = new Memcache; FunctionData::$static  ->connect("127.0.0.1" , 11215 ) or die ("Could not connect");};} ;
		{if( FunctionData::$static  ->get( "mail_reginfo_" .$email_address )==null) FunctionData::$static  ->set( "mail_reginfo_" .$email_address , $account_reg->getBinary() );else  FunctionData::$static  ->replace( "mail_reginfo_" .$email_address , $account_reg->getBinary() );} ;
	}
	static function readFriends($identify){
		{if(!isset( FunctionData::$static  ) ||  FunctionData::$static  ==null){ FunctionData::$static   = new Memcache; FunctionData::$static  ->connect("127.0.0.1" , 11215 ) or die ("Could not connect");};} ;
		$friends_data =  FunctionData::$static  ->get( "friends_" .$identify ) ;
		if($friends_data != null){
			return DataFriends::swap(ByteBuffer::wrap( $friends_data ) );
		}
		return new DataFriends();
	}
	static function writeFriends($identify,$friends){
		{if(!isset( FunctionData::$static  ) ||  FunctionData::$static  ==null){ FunctionData::$static   = new Memcache; FunctionData::$static  ->connect("127.0.0.1" , 11215 ) or die ("Could not connect");};} ;
		{if( FunctionData::$static  ->get( "friends_" .$identify )==null) FunctionData::$static  ->set( "friends_" .$identify , $friends->getBinary() );else  FunctionData::$static  ->replace( "friends_" .$identify , $friends->getBinary() );} ;
	}
	static function connectIdAndGuest($id,$guest_identify){
		{if(!isset( FunctionData::$static  ) ||  FunctionData::$static  ==null){ FunctionData::$static   = new Memcache; FunctionData::$static  ->connect("127.0.0.1" , 11215 ) or die ("Could not connect");};} ;
		$idstatus =  FunctionData::$static  ->get( "id_status_" .$id ) ;
		if($idstatus == 0 ){
			$numof_newid =  FunctionData::$static  ->get( "mng_numof_newid"  ) ;
			$numof_newid--;
			{if( FunctionData::$static  ->get( "mng_numof_newid"  )==null) FunctionData::$static  ->set( "mng_numof_newid"  , $numof_newid );else  FunctionData::$static  ->replace( "mng_numof_newid"  , $numof_newid );} ;
			{if( FunctionData::$static  ->get( "mng_numof_guest"  )!=null) FunctionData::$static  ->increment( "mng_numof_guest"  );else  FunctionData::$static  ->set( "mng_numof_guest"  ,1);} ;
		}
		{if( FunctionData::$static  ->get( "guest_" .$guest_identify )==null) FunctionData::$static  ->set( "guest_" .$guest_identify , $id );else  FunctionData::$static  ->replace( "guest_" .$guest_identify , $id );} ;
		{if( FunctionData::$static  ->get( "id_" .$id )==null) FunctionData::$static  ->set( "id_" .$id , unpack('C*', $guest_identify )  );else  FunctionData::$static  ->replace( "id_" .$id , unpack('C*', $guest_identify )  );} ;
		{if( FunctionData::$static  ->get( "id_status_" .$id )==null) FunctionData::$static  ->set( "id_status_" .$id , 2  );else  FunctionData::$static  ->replace( "id_status_" .$id , 2  );} ;
	}
	static function checkGuestIDUsed($guestid){
		{if(!isset( FunctionData::$static  ) ||  FunctionData::$static  ==null){ FunctionData::$static   = new Memcache; FunctionData::$static  ->connect("127.0.0.1" , 11215 ) or die ("Could not connect");};} ;
		$id =  FunctionData::$static  ->get( "guest_" .$guestid ) ;
		if($id != null)return true;
		return false;
	}
	static function getGuestID($guestid){
		{if(!isset( FunctionData::$static  ) ||  FunctionData::$static  ==null){ FunctionData::$static   = new Memcache; FunctionData::$static  ->connect("127.0.0.1" , 11215 ) or die ("Could not connect");};} ;
		$id =  FunctionData::$static  ->get( "guest_" .$guestid ) ;
		if($id != null)return $id;
		return -1;
	}
	static function readGuest($guestid){
		{if(!isset( FunctionData::$static  ) ||  FunctionData::$static  ==null){ FunctionData::$static   = new Memcache; FunctionData::$static  ->connect("127.0.0.1" , 11215 ) or die ("Could not connect");};} ;
		$data =  FunctionData::$static  ->get( "guest_data_" .$guestid ) ;
		if($data != null){
			return DataGuest::swap(ByteBuffer::wrap( $data ) );
		}
		return null;
	}
	static function writeGuest($guestid, $guest){
		{if(!isset( FunctionData::$static  ) ||  FunctionData::$static  ==null){ FunctionData::$static   = new Memcache; FunctionData::$static  ->connect("127.0.0.1" , 11215 ) or die ("Could not connect");};} ;
		{if( FunctionData::$static  ->get( "guest_data_" .$guestid )==null) FunctionData::$static  ->set( "guest_data_" .$guestid , $guest->getBinary() );else  FunctionData::$static  ->replace( "guest_data_" .$guestid , $guest->getBinary() );} ;
	}
	static function isSystemAreaExists($areaname){
		{if(!isset( FunctionData::$static  ) ||  FunctionData::$static  ==null){ FunctionData::$static   = new Memcache; FunctionData::$static  ->connect("127.0.0.1" , 11215 ) or die ("Could not connect");};} ;
		$sarea =  FunctionData::$static  ->get( "area_system_" .$areaname ) ;
		return ($sarea!=null);
	}
	static function isUserAreaExists($areaname){
		{if(!isset( FunctionData::$static  ) ||  FunctionData::$static  ==null){ FunctionData::$static   = new Memcache; FunctionData::$static  ->connect("127.0.0.1" , 11215 ) or die ("Could not connect");};} ;
		$uarea =  FunctionData::$static  ->get( "area_user_" .$areaname ) ;
		return ($uarea!=null);
	}
	static function readAreasManager(){
		{if(!isset( FunctionData::$static  ) ||  FunctionData::$static  ==null){ FunctionData::$static   = new Memcache; FunctionData::$static  ->connect("127.0.0.1" , 11215 ) or die ("Could not connect");};} ;
		$amng_data =  FunctionData::$static  ->get( "area_manager"  ) ;
		$mng = null;
		if($amng_data == null){
			$mng = new DataAreasManager();
		}else{
			$mng = DataAreasManager::swap(ByteBuffer::wrap( $amng_data ) );
		}
		return $mng;
	}
	static function writeAreaManager($areamanager){
		{if(!isset( FunctionData::$static  ) ||  FunctionData::$static  ==null){ FunctionData::$static   = new Memcache; FunctionData::$static  ->connect("127.0.0.1" , 11215 ) or die ("Could not connect");};} ;
		{if( FunctionData::$static  ->get( "area_manager"  )==null) FunctionData::$static  ->set( "area_manager"  , $areamanager->getBinary() );else  FunctionData::$static  ->replace( "area_manager"  , $areamanager->getBinary() );} ;
	}
	static function isSystemGroupExists($groupname){
		{if(!isset( FunctionData::$static  ) ||  FunctionData::$static  ==null){ FunctionData::$static   = new Memcache; FunctionData::$static  ->connect("127.0.0.1" , 11215 ) or die ("Could not connect");};} ;
		$sgroup =  FunctionData::$static  ->get( "group_system_" .$groupname ) ;
		return ($sgroup!=null);
	}
	static function isUserGroupExists($groupname){
		{if(!isset( FunctionData::$static  ) ||  FunctionData::$static  ==null){ FunctionData::$static   = new Memcache; FunctionData::$static  ->connect("127.0.0.1" , 11215 ) or die ("Could not connect");};} ;
		$ugroup =  FunctionData::$static  ->get( "group_user_" .$groupname ) ;
		return ($ugroup!=null);
	}
	static function readGroupsManager(){
		{if(!isset( FunctionData::$static  ) ||  FunctionData::$static  ==null){ FunctionData::$static   = new Memcache; FunctionData::$static  ->connect("127.0.0.1" , 11215 ) or die ("Could not connect");};} ;
		$gmng_data =  FunctionData::$static  ->get( "group_manager"  ) ;
		$mng = null;
		if($gmng_data == null){
			$mng = new DataGroupsManager();
		}else{
			$mng = DataGroupsManager::swap(ByteBuffer::wrap( $gmng_data ) );
		}
		return $mng;
	}
	static function writeGroupsManager($mng){
		{if(!isset( FunctionData::$static  ) ||  FunctionData::$static  ==null){ FunctionData::$static   = new Memcache; FunctionData::$static  ->connect("127.0.0.1" , 11215 ) or die ("Could not connect");};} ;
		{if( FunctionData::$static  ->get( "group_manager"  )==null) FunctionData::$static  ->set( "group_manager"  , $mng->getBinary() );else  FunctionData::$static  ->replace( "group_manager"  , $mng->getBinary() );} ;
	}
	static function readGroupUsers($group_name){
		{if(!isset( FunctionData::$static  ) ||  FunctionData::$static  ==null){ FunctionData::$static   = new Memcache; FunctionData::$static  ->connect("127.0.0.1" , 11215 ) or die ("Could not connect");};} ;
		if($data =  FunctionData::$static  ->get( "group_users_system_" .$group_name ) ){
			return DataGroupUsers::swap(ByteBuffer::wrap( $data ) );
		}
		return null;
	}
	static function writeGroupUsers($group_name,$group_users){
		{if(!isset( FunctionData::$static  ) ||  FunctionData::$static  ==null){ FunctionData::$static   = new Memcache; FunctionData::$static  ->connect("127.0.0.1" , 11215 ) or die ("Could not connect");};} ;
		{if( FunctionData::$static  ->get( "group_users_system_" .$group_name )==null) FunctionData::$static  ->set( "group_users_system_" .$group_name , $group_users->getBinary() );else  FunctionData::$static  ->replace( "group_users_system_" .$group_name , $group_users->getBinary() );} ;
	}
	static function readGroup($group_name){
		{if(!isset( FunctionData::$static  ) ||  FunctionData::$static  ==null){ FunctionData::$static   = new Memcache; FunctionData::$static  ->connect("127.0.0.1" , 11215 ) or die ("Could not connect");};} ;
		$data =  FunctionData::$static  ->get(  "group_system_" .$group_name ) ;
		if($data != null){
			return DataGroup::swap(ByteBuffer::wrap( $data ) );
		}
		{Error::getInstance() ->addError( 1 , "readGroup null ".$group_name );} ;
		return null;
	}
	static function writeGroup($group_name,$group){
		{if(!isset( FunctionData::$static  ) ||  FunctionData::$static  ==null){ FunctionData::$static   = new Memcache; FunctionData::$static  ->connect("127.0.0.1" , 11215 ) or die ("Could not connect");};} ;
		{if( FunctionData::$static  ->get(  "group_system_" .$group_name )==null) FunctionData::$static  ->set(  "group_system_" .$group_name , $group->getBinary() );else  FunctionData::$static  ->replace(  "group_system_" .$group_name , $group->getBinary() );} ;
	}
	static function readUserGroups($email_address){
		{if(!isset( FunctionData::$static  ) ||  FunctionData::$static  ==null){ FunctionData::$static   = new Memcache; FunctionData::$static  ->connect("127.0.0.1" , 11215 ) or die ("Could not connect");};} ;
		if($data =  FunctionData::$static  ->get( "mail_group_" .$email_address ) ){
			return DataUserGroups::swap(ByteBuffer::wrap( $data ) );
		}
		return new DataUserGroups();
	}
	static function writeUserGroups($email_address,$join_groups){
		{if(!isset( FunctionData::$static  ) ||  FunctionData::$static  ==null){ FunctionData::$static   = new Memcache; FunctionData::$static  ->connect("127.0.0.1" , 11215 ) or die ("Could not connect");};} ;
		{if( FunctionData::$static  ->get( "mail_group_" .$email_address )==null) FunctionData::$static  ->set( "mail_group_" .$email_address , $join_groups->getBinary() );else  FunctionData::$static  ->replace( "mail_group_" .$email_address , $join_groups->getBinary() );} ;
	}
	static function registerAnAppId(){
		{if(!isset( FunctionData::$static  ) ||  FunctionData::$static  ==null){ FunctionData::$static   = new Memcache; FunctionData::$static  ->connect("127.0.0.1" , 11215 ) or die ("Could not connect");};} ;
		$next_id =  FunctionData::$static  ->get( "app_next_id"  ) ;
		if($next_id == null){
			$next_id = 1;
		}
		{if( FunctionData::$static  ->get( "app_next_id"  )==null) FunctionData::$static  ->set( "app_next_id"  , $next_id+1 );else  FunctionData::$static  ->replace( "app_next_id"  , $next_id+1 );} ;
		return $next_id;
	}
	static function readAppManager(){
		{if(!isset( FunctionData::$static  ) ||  FunctionData::$static  ==null){ FunctionData::$static   = new Memcache; FunctionData::$static  ->connect("127.0.0.1" , 11215 ) or die ("Could not connect");};} ;
		$data =  FunctionData::$static  ->get( "app_manager"  ) ;
		if($data != null){
			return DataAppManager::swap(ByteBuffer::wrap( $data ) );
		}
		return new DataAppManager();
	}
	static function writeAppManager($app_mng){
		{if(!isset( FunctionData::$static  ) ||  FunctionData::$static  ==null){ FunctionData::$static   = new Memcache; FunctionData::$static  ->connect("127.0.0.1" , 11215 ) or die ("Could not connect");};} ;
		{if( FunctionData::$static  ->get( "app_manager"  )==null) FunctionData::$static  ->set( "app_manager"  , $app_mng->getBinary() );else  FunctionData::$static  ->replace( "app_manager"  , $app_mng->getBinary() );} ;
	}
	static function readApp($app_id){
		{if(!isset( FunctionData::$static  ) ||  FunctionData::$static  ==null){ FunctionData::$static   = new Memcache; FunctionData::$static  ->connect("127.0.0.1" , 11215 ) or die ("Could not connect");};} ;
		$data =  FunctionData::$static  ->get( "app_id_" .$app_id ) ;
		$app = null;
		if($data != null){
			$app = DataApp::swap(ByteBuffer::wrap( $data ) );
		}
		return $app;
	}
	static function writeApp($app_id,$app){
		{if(!isset( FunctionData::$static  ) ||  FunctionData::$static  ==null){ FunctionData::$static   = new Memcache; FunctionData::$static  ->connect("127.0.0.1" , 11215 ) or die ("Could not connect");};} ;
		{if( FunctionData::$static  ->get( "app_id_" .$app_id )==null) FunctionData::$static  ->set( "app_id_" .$app_id , $app->getBinary() );else  FunctionData::$static  ->replace( "app_id_" .$app_id , $app->getBinary() );} ;
	}
	static function readCertificates($mail_address){
		{if(!isset( FunctionData::$static  ) ||  FunctionData::$static  ==null){ FunctionData::$static   = new Memcache; FunctionData::$static  ->connect("127.0.0.1" , 11215 ) or die ("Could not connect");};} ;
		$data =  FunctionData::$static  ->get( "cers_" .$mail_address ) ;
		if($data != null){
			return DataUserCertificates::swap(ByteBuffer::wrap( $data ) );
		}
		return new DataUserCertificates();
	}
	static function writeCertificates($mail_address,$cers){
		{if(!isset( FunctionData::$static  ) ||  FunctionData::$static  ==null){ FunctionData::$static   = new Memcache; FunctionData::$static  ->connect("127.0.0.1" , 11215 ) or die ("Could not connect");};} ;
		{if( FunctionData::$static  ->get( "cers_" .$mail_address )==null) FunctionData::$static  ->set( "cers_" .$mail_address , $cers->getBinary() );else  FunctionData::$static  ->replace( "cers_" .$mail_address , $cers->getBinary() );} ;
	}
	static function mergeFbAccountToID($ID, $fbid, $fbname){
		{if(!isset( FunctionData::$static  ) ||  FunctionData::$static  ==null){ FunctionData::$static   = new Memcache; FunctionData::$static  ->connect("127.0.0.1" , 11215 ) or die ("Could not connect");};} ;
		if(self::checkIDValid($ID)){
			$key_fbid = "fbid_" .$fbid;
			$key_idfb = "idfb_" .$ID;
			$cid =  FunctionData::$static  ->get( $key_fbid ) ;
			$cfbid =  FunctionData::$static  ->get( $key_idfb ) ;
			if($cid == null && $cfbid == null){
				{if( FunctionData::$static  ->get( $key_fbid )==null) FunctionData::$static  ->set( $key_fbid , $ID );else  FunctionData::$static  ->replace( $key_fbid , $ID );} ;
				{if( FunctionData::$static  ->get( $key_idfb )==null) FunctionData::$static  ->set( $key_idfb , $fbid );else  FunctionData::$static  ->replace( $key_idfb , $fbid );} ;
				return true;
			}else{
			}
		}
		return false;
	}
	static function getFbIdByUserId($uid){
		$key_idfb = "idfb_" .$ID;
		{if(!isset( FunctionData::$static  ) ||  FunctionData::$static  ==null){ FunctionData::$static   = new Memcache; FunctionData::$static  ->connect("127.0.0.1" , 11215 ) or die ("Could not connect");};} ;
		$cid =  FunctionData::$static  ->get( $key_idfb ) ;
		return $cid;
	}
	static function getIdByFacebookAccount($fbid){
		$key_fbid = "fbid_" .$fbid;
		{if(!isset( FunctionData::$static  ) ||  FunctionData::$static  ==null){ FunctionData::$static   = new Memcache; FunctionData::$static  ->connect("127.0.0.1" , 11215 ) or die ("Could not connect");};} ;
		$cid =  FunctionData::$static  ->get( $key_fbid ) ;
		if($cid != null)return $cid;
		return -1;
	}
	static function registerAFacebookAppId(){
		{if(!isset(FunctionData::$fbdbconnect ) || FunctionData::$fbdbconnect ==null){FunctionData::$fbdbconnect  = new Memcache;FunctionData::$fbdbconnect ->connect("127.0.0.1" , 11214 ) or die ("Could not connect to Facebook Token Database");};} ;
		$next_id = FunctionData::$fbdbconnect ->get( "fbnext_"  ) ;
		if($next_id == null){
			$next_id = 1;
		}
		{if(FunctionData::$fbdbconnect ->get( "fbnext_"  )==null)FunctionData::$fbdbconnect ->set( "fbnext_"  , $next_id+1 );else FunctionData::$fbdbconnect ->replace( "fbnext_"  , $next_id+1 );} ;
		return $next_id;
	}
	  static function getFBToken($fbappid, $userid){
		{if(!isset(FunctionData::$fbdbconnect ) || FunctionData::$fbdbconnect ==null){FunctionData::$fbdbconnect  = new Memcache;FunctionData::$fbdbconnect ->connect("127.0.0.1" , 11214 ) or die ("Could not connect to Facebook Token Database");};} ;
		$key = "fbtoken_" .$fbappid."_".$userid;
		$data = FunctionData::$fbdbconnect ->get( $key ) ;
		if($data != null){
			return DataFbToken::swap(ByteBuffer::wrap( $data ) );
		}
		return null;
	}
	static function setFBToken($fbappid, $userid, $tokenobj){
		{if(!isset(FunctionData::$fbdbconnect ) || FunctionData::$fbdbconnect ==null){FunctionData::$fbdbconnect  = new Memcache;FunctionData::$fbdbconnect ->connect("127.0.0.1" , 11214 ) or die ("Could not connect to Facebook Token Database");};} ;
		$key = "fbtoken_" .$fbappid."_".$userid;
		{if(FunctionData::$fbdbconnect ->get( $key )==null)FunctionData::$fbdbconnect ->set( $key ,  $tokenobj->getBinary() );else FunctionData::$fbdbconnect ->replace( $key ,  $tokenobj->getBinary() );} ;
	}
}
?>